//
//  UIImage+Common.m
//  project-demo-oc
//
//  Created by 赵隆杰 on 2021/10/15.
//

#import "UIImage+Common.h"

@implementation UIImage (Common)

- (UIImage *)imageWithRadius:(CGFloat)radius ofSize:(CGSize)size
{
    
    
    CGRect rect = CGRectMake(0, 0, size.width, size.height);
    
    UIGraphicsBeginImageContextWithOptions(size, NO, UIScreen.mainScreen.scale);
    CGContextAddPath(UIGraphicsGetCurrentContext(), [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:radius].CGPath);
    CGContextClip(UIGraphicsGetCurrentContext());
    [self drawInRect:rect];
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    return image;
}

@end
